/*
 * TIM.h
 *
 *  Created on: Nov 14, 2020
 *      Author: Jiarun
 */
#ifndef __TIM_H
#define __TIM_H

/* ----------------------------------Includes --------------------------------*/
#include "main.h"
#include "stm32f1xx_hal_tim.h"


class TIM
{
	public:
		TIM(TIM_TypeDef *TIM, uint32_t Prescaler, uint32_t Period, uint32_t Preempt = 0xff, uint32_t Sub = 0xff);
		~TIM();
	
		IRQn_Type decideTIM_IRQn(TIM_TypeDef *TIM);
		void EnableIRQ(void);
			
		TIM_HandleTypeDef tim;
	private:
		IRQn_Type TIM_IRQn;
};

class PWM: public TIM
{
	public:
		PWM(TIM_TypeDef *TIM, uint32_t Prescaler, uint32_t Period);
		~PWM();
		
		void setPulse(uint32_t Channel, uint32_t Pulse);
};

#ifdef __cplusplus
 extern "C" {
#endif

	 
#ifdef __cplusplus
}
#endif

#endif /* __TIM_H */
